﻿@{
    ViewData["Title"] = "AddSuppliers";
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.21/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">供应商编码</label>
            <div class="layui-input-block">
                <input type="text" name="supplierManagementCode" lay-verify="required" placeholder="请输入供应商编码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商名称</label>
            <div class="layui-input-block">
                <input type="text" name="supplierName" lay-verify="required" placeholder="请输入供应商名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商简称</label>
            <div class="layui-input-block">
                <input type="text" name="supplierAbbreviation" lay-verify="required" placeholder="请输入供应商简称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商等级</label>
            <div class="layui-input-block">
                <select name="supplierGrade" lay-filter="aihao" lay-verify="required">
                    <option value=""></option>
                    <option value="优质供应商">优质供应商</option>
                    <option value="正常" selected>正常</option>
                    <option value="重点关注">重点关注</option>
                    <option value="劣质供应商">劣质供应商</option>
                    <option value="黑名单">黑名单</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">供应商评分</label>
                <div class="layui-input-inline" style="width: 200px;">
                    <input lay-verify="required" type="number" name="supplierScore" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="number">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商电话</label>
            <div class="layui-input-block">
                <input type="text" name="supplierPhone" lay-verify="required" placeholder="请输入供应商电话" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="radio" name="state" value="true" title="是" checked>
                <input type="radio" name="state" value="false" title="否">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script src="~/libs/jquery/jquery.js"></script>
    <script src="~/libs/layui-v2.5.6/layui/layui.js"></script>
    <script>
         layui.use(['form', 'laydate', 'util'], function(){
           var form = layui.form;
           var layer = layui.layer;
           var laydate = layui.laydate;
           var util = layui.util;
           // 提交事件
           form.on('submit(demo1)', function(data){
               // console.log(22222)
             var field = data.field; // 获取表单字段值
             // console.table(1111111,field);
             $.ajax({
                 url:'/Suppliers/Add',
                 type:'post',
                 async:false,
                 data:field,
                 datatype:'json',
                 success:function(res){
                        // console.table(333,res);
                      if(res.code>0){
                      var index = parent.layer.getFrameIndex(window.name); /* 先得到当前iframe层的索引 */
                             parent.layer.close(index); /* 再执行关闭 */
                              parent.location.reload(); /* 刷新父页面，即列表页面 */
                           layer.alert('新增成功');
                      }
                     alert('新增成功')
                 }
             })
             return false; // 阻止默认 form 跳转
            });
        });
    </script>
</body>
</html>

